
<template src='./tpl.html'></template>
<script>
import { CONSENT_GET_CONSENT_PATIENT_INFO, CONSENT_GET_CONSENT_INFO, CONSENT_GET_TEMPLATE_INFO, CONSENT_SIGN } from "_SERVICES/api";
import { simDeepCopy, getStorage, setStorage,isInteger } from "UTILS/util";
import draggableItem from 'MODULES/CST/components/DraggableItem'

export default {
  name: "consentInfo",
  components: {
    draggableItem
  },
  data() {
    return {
      queryInfo: {
        TYPE: "3" //1 新增 2编辑 //3查看已签署信息 //4 查看模板
      },
      TPL_FORMAT: [],
      listLoading: false,
    };
  },
  created() {
    //如果是直接传JCH 就表示这是新增一个知情同意书 带出病人信息
    //如果是主键传CONSTENT_ID 表示这是编辑一个知情同意书

    if (this.$route.query) {
      this.queryInfo = this.$route.query;
    }

    this.get_consent_info();
  },

  methods: {
  
    get_consent_info() {
      this.listLoading = true;
      CONSENT_GET_CONSENT_INFO({
        SID: this.queryInfo.CONSENT_ID
      }).then((res) => {
        // console.log("具体的一份同意书",res.data)

        this.listLoading = false;

        this.templateInfo = res.data.templateInfo; //模板信息
        let list = JSON.parse(res.data.templateInfo.TPL_FORMAT);
        let signContentInfo = res.data.signContentInfo; //签署信息

        this.signInfo = JSON.parse(JSON.stringify(res.data.signInfo));

        this.brInfo = res.data.signInfo;//病人信息

        if(this.brInfo.BRXM){
          document.title= this.brInfo.BRXM
        }

        // console.log("签署保存的字段",signContentInfo)

        list.forEach((item, index) => {
          signContentInfo.forEach((inner, inner_index) => {

            if (item.field_name == inner.FIELD_NAME) {
              let value = inner.CONTENT || inner.CONTENT_CLOB;
              if (value !== null) {
                item.field_value = value;
              }
            }


            // if ((item.type == 'sign2' || item.type == 'sign3')) {
            //   if (item.field_name == inner.FIELD_NAME && inner.CONTENT_CLOB !== null) {
            //     item.field_value = inner.CONTENT_CLOB
            //   }

            // } else {
            //   if (item.field_name == inner.FIELD_NAME && inner.CONTENT !== null) {
            //     item.field_value = inner.CONTENT
            //   }
            // }

          })
        });
        this.TPL_FORMAT = list;
      }).catch((e) => {
        this.listLoading = false;
      })
    },
  },
};
</script>

<style lang="less">
.consent-info {
  *{
    color:#000 !important;
    font-family: "Microsoft YaHei", Arial !important;
    font-size: 15px !important;
  }
  div{
   
  }
   .input_show
  {
    text-align: center !important;   
  }
}
</style>
